$(function () {
    // alert();
    /*获取店铺  */
    $.ajax({
        type: "get",
        url: "http://193.112.55.79:9090/api/getgsshop",
        dataType: "json",
        success: function (response) {
           // console.log(response.result);
          $html=  template('shoptp',response.result);
          $("#shop").html($html);
        }
    });

    /* 获取地区 */
    $.ajax({
        type: "get",
        url: "http://193.112.55.79:9090/api/getgsshoparea",
        dataType: "json",
        success: function (response) {
            //console.log(response.result);
            $html=  template('areatp',response.result);
            $("#area").html($html);
        }
    });
    /* 获取商品 */
    /* getgsproduct(0,0);
    function getgsproduct($a,$b){
        $.ajax({
            type: "get",
            url: "http://193.112.55.79:9090/api/getgsproduct",
            data: {
                shopid :$a,
                areaid : $b
            },
            dataType: "json",
            success: function (response) {
                $html = template('producttp',response.result);
                console.log(response.result);
                // $("duct").html($html);
            }
        });
   
    } */

    getgsproduct(0,0)

function getgsproduct(a,b){
    $.ajax({
        type: "get",
        url: "http://193.112.55.79:9090/api/getgsproduct",
        data: {
            shopid :a,
            areaid : b
        },
        dataType: "json",
        success: function (response) {
            $html=  template('producttp',response.result);
            //console.log(response.result);
           // console.log($html);
            $("#duct").html($html);
        }
    });
}
   
/*====================点击获取商品列表内容=========================== */
    // $('#shop').on('click','option',function(){
    //     alert();
    // })
    // $("#shop").on('click',"option",function(){
    //     alert();
    // })
     /* ===================== 店铺=============================== */

    $("#shop").change(function () { 
        // e.preventDefault();
        // alert();      
      $shopId =  $(this).children('option:selected').attr("shopId");
      console.log($shopId);
    //   $areaId
      $areaId =  $("#area").children('option:selected').attr("areaId");
      console.log($areaId);
      getgsproduct($shopId,$areaId)

    });
    /* =====================地区=============================== */
    $("#area").change(function () { 
        // e.preventDefault();
        // alert();      
      $shopId =  $("#shop").children('option:selected').attr("shopId");
      console.log($shopId);
    //   $areaId
      $areaId =  $(this).children('option:selected').attr("areaId");
      console.log($areaId);
      getgsproduct($shopId,$areaId)

    });



// $("#jiage").on('click','li',function(){
//     alert();
// }) 
    


})

